import React, {
  Component,
  useState,
  useEffect
} from "react";
import {
  Text,
  TouchableHighlight,
  View,
  Image,
} from "react-native";
import styles from "./task-sheet";
import {
  platform
} from "../../baseData";
import Navigation from '../../navigation';

export default function Task(props) {
  const router = () => {
    Navigation(props.router, {
      id: props.id,
    });
  }

  return (
    <TouchableHighlight underlayColor="#fff" onPress={()=>{router()}} style={[styles.listItem]}>
      <View style={styles.listItemContent}>
        <View style={styles.listItemLeft}>
          <View>
            <Image resizeMode="contain" style={styles.icon} source={platform['order'].image} />
          </View>
          <View>
            <Text style={styles.platformName}>
              {platform[props.platform].name}
            </Text>
          </View>
        </View>

        <View style={styles.dish}></View>

        <View style={styles.listItemRight}>
          <Text style={styles.no}>
            {props.No}
          </Text>
          <Text style={styles.remain}>
            余量: {props.remaining_applicant_num}
          </Text>
          <Text ellipsizeMode="tail" numberOfLines={1} style={styles.name}>
            类型: {props.name}
          </Text>
        </View>
      </View>
    </TouchableHighlight>
  )
}